﻿using System;
using System.Data;
using System.Web.UI;
using MyWeb.Business;

namespace MyWeb.TrangChinh.UC
{
    public partial class ucProducts : UserControl
    {
        private readonly ProductService _productService = new ProductService();
        private string _headerName = "";

        public string HeaderName
        {
            get { return _headerName; }
            set { _headerName = value; }
        }

        public string StringQuery { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                lblHeader.Text = _headerName;
                DataTable tableProduct = _productService.Product_SelectTop(StringQuery);
                rptProduct.DataSource = tableProduct;
                rptProduct.DataBind();
            }
        }

        protected void rptProduct_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
        {
            string id = e.CommandArgument.ToString();
            if (e.CommandName == "Image")
            {
                Response.Redirect("~/TrangChinh/Product.aspx?idProduct=" + id);
            }
        }
    }
}